<?php

class AutoUidBehavior extends CActiveRecordBehavior {
	public $field = 'uid';

	public function beforeSave($event)
	{
		$owner = $this->getOwner();
		if($owner->isNewRecord)
			$owner->{$this->field} = Yii::app()->user->id;
		return true;
	}
}

?>